/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Home-pc
 * Date: 2023-09-23
 * Time: 11:57
 */
//单例模式（懒汉模式）
class SingletonLazy{
    private static  volatile SingletonLazy instance =null;

    public static SingletonLazy getInstance() {
        if(instance==null){
            synchronized (SingletonLazy.class)
            {
                if (instance == null) {
                    instance=new SingletonLazy();
                }
            }
        }
        return instance;
    }
    private SingletonLazy(){

    }
}
public class Demo16 {
    public static void main(String[] args) {
        SingletonLazy s1=SingletonLazy.getInstance();
        SingletonLazy s2=SingletonLazy.getInstance();
        System.out.println(s1==s2);
    }
}
